package com.zhentao.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 目标类型枚举
 * @author zhentao
 * @date 2024-12-19
 */
@Getter
@AllArgsConstructor
public enum TargetTypeEnum {
    
    /**
     * 参数定义
     */
    PARAM_DEFINITION("PARAM_DEFINITION", "参数定义", "参数的基本定义信息"),
    
    /**
     * 参数值
     */
    PARAM_VALUE("PARAM_VALUE", "参数值", "参数的具体值配置"),
    
    /**
     * 参数规则
     */
    PARAM_RULE("PARAM_RULE", "参数规则", "参数的校验和处理规则"),
    
    /**
     * 参数分类
     */
    PARAM_CATEGORY("PARAM_CATEGORY", "参数分类", "参数的分类管理"),
    
    /**
     * 参数配置
     */
    PARAM_CONFIG("PARAM_CONFIG", "参数配置", "系统参数配置"),
    
    /**
     * 权限配置
     */
    PERMISSION("PERMISSION", "权限配置", "参数访问权限配置");
    
    private final String code;
    private final String name;
    private final String description;
    
    /**
     * 根据代码获取枚举
     */
    public static TargetTypeEnum getByCode(String code) {
        for (TargetTypeEnum targetType : values()) {
            if (targetType.getCode().equals(code)) {
                return targetType;
            }
        }
        return null;
    }
    
    /**
     * 是否为有效的目标类型代码
     */
    public static boolean isValidCode(String code) {
        return getByCode(code) != null;
    }
}

